import globalConstants from "../constants/global";

export interface IGlobal {
  loading: boolean;
}

export const globalState: IGlobal = {
  loading: false,
};

const globalReducer = (state = globalState, action: any) => {
  const { type } = action;
  switch (type) {
    case globalConstants.CHANGE_LOADING: {
      return { ...state, loading: !state.loading };
    }
    default: {
      return { ...state };
    }
  }
};

export default globalReducer;
